﻿import plugin from '../../../lib/plugins/plugin.js'
const botname = global.Bot.nickname; // bot名字
const _path = process.cwd();
import { Config } from '../components/index.js'

import {createRequire} from "module";
const require = createRequire(import.meta.url);
const fs =require('fs')

const imgs = `file:///${_path}/plugins/js-box-plugin/resources/huagao-imgs`  //图库地址

//图库指向
let img_1 = `${imgs}/img_1.gif`
let img_2 = `${imgs}/img_2.png`
let img_3 = `${imgs}/img_3.gif`
let img_4 = `${imgs}/img_4.png`
let img_5 = `${imgs}/img_5.gif`
let img_6 = `${imgs}/img_6.gif`
let img_7 = `${imgs}/img_7.gif`

export class flower extends plugin {
constructor () {
super({
name: '花糕在吗',
dsc: '结合(花糕)和(伊伊在吗)两大插件',
event: 'message',
priority: 5000,
rule: [
{
reg: `^#?(在)?(吗|嘛|干吗|干嘛|哪|那|哪里|那里|么)?(丫|鸭|呀|呐|呢|喵)?[～~.。，,！!、？]?${botname}?(在)?(吗|嘛|干吗|干嘛|哪|那|哪里|那里|么)?(丫|鸭|呀|呐|呢|喵)?[～~.。，,！!、？]?$`,
fnc: 'isflower'
},
{
reg: '^#*[\u4e00-\u9fa5]+(岚|风)$', 
//此处括号里填上机器人名字的最后一个字，多个字用分隔符隔开
fnc: 'flower'
}
]
})
}

async flower (e) {
let set = await Config.admin_set
let isplugin = set.huagao
if (!isplugin) return false
let char = e.toString()
let charArr = char.split('').join('——')
let botArr = botname.split('').join('——')
let number = Math.round(Math.random() * 100 + 1)
let msg = ''
if (number < 10) {
msg = `是${botname}啦！气气`
} else if (number < 20) {
msg = `${charArr}——是——谁——啦~`
} else if (number < 30) {
msg = `是${botname}好叭！！`
} else if (number < 40) {
msg = `啊呀~才不是什么${char}啦....`
} else if (number < 50) {
msg = `${char}是什么？可以吃吗？`
} else if (number < 60) {
msg = `不许叫我${char}啦！！`
} else if (number < 70) {
msg = `我叫${char}，不是${botname}——！#￥#%￥不对，我叫${char}，*#%@我——叫——${botarr}——我要被你气死了！！！`
} else if (number < 80) {
msg = `啊呀~不要再叫我${char}啦.....`
} else if (number < 90) {
msg = `呜呜呜麻麻有人欺负我，一直乱叫我名字.....你看又有人叫我${char}了！`
}  else {
await this.reply('我——是——！！')
setTimeout(async () => {
await this.reply(`${botArr}——！！`)
}, 500)
setTimeout(async () => {
await this.reply('气——气！！')
}, 1000)
return true
}
await this.reply(msg)
return true
}

async isflower(e) {
let set = await Config.admin_set
let isplugin = set.huagao
if (!isplugin) return false
let number = Math.round(Math.random() * 100 + 1)
let msg = ''
if (number < 15) {
msg = [`来了来了，${botname}一直在呢~\n`,
segment.image(`${img_1}`)]
} else if (number < 30) {
msg = [`你喊${botname}做什么，${botname}也是很忙的好吧！\n`,
segment.image(`${img_2}`)]
} else if (number < 45) {
msg = [`${botname}在哦，有什么事吗?\n`,
segment.image(`${img_3}`)]
} else if (number < 60) {
msg = [segment.image(`${img_4}`)]
} else if (number < 75) {
msg = [`你干嘛呢~好烦哦~\n`,
segment.image(`${img_5}`)]
} else if (number < 90) {
msg = [`啊呀~${botname}不就在这吗?\n`,
segment.image(`${img_6}`)]
} else {
await this.reply('我——！')
setTimeout(async () => {
await this.reply('在——！')
}, 300)
setTimeout(async () => {
await this.reply('呢——！')
}, 600)
setTimeout(async () => {
await this.reply([segment.image(`${img_7}`)])
}, 900)
return true
}
await this.reply(msg)
return true
}
}
